﻿Imports Microsoft.VisualBasic
Imports ADOEntity

Public Class clsSystemConfig
    Private systemConfigEntity As systemConfigEntities

    Private strUserExpireDate As String
    Private strUserBeginDate As String
    Private strPwdExpireDateAdmin As String
    Private strPwdExpireDateUser As String
    Private strPassword As String
    Dim clsDateFormat As clsDateFormat
    Dim tblSystemConfig As IList(Of SSYSTEMCONFIG)

    Public Property userExpireDate() As String
        Get
            Return strUserExpireDate
        End Get
        Set(ByVal value As String)
            strUserExpireDate = value
        End Set
    End Property

    Public Property UserBeginDate() As String
        Get
            Return strUserBeginDate
        End Get
        Set(ByVal value As String)
            strUserBeginDate = value
        End Set
    End Property

    Public Property PwdExpireDateAdmin() As String
        Get
            Return strPwdExpireDateAdmin
        End Get
        Set(ByVal value As String)
            strPwdExpireDateAdmin = value
        End Set
    End Property

    Public Property PwdExpireDateUser() As String
        Get
            Return strPwdExpireDateUser
        End Get
        Set(ByVal value As String)
            strPwdExpireDateUser = value
        End Set
    End Property

    Public Property Password() As String
        Get
            Return strPassword
        End Get
        Set(ByVal value As String)
            strPassword = value
        End Set
    End Property

    Public Sub New()
        systemConfigEntity = New systemConfigEntities
        tblSystemConfig = (From tblSystem In systemConfigEntity.SSYSTEMCONFIG).ToList

    End Sub


    Public Sub setdefaultValueDate()
        clsDateFormat = New clsDateFormat
        Dim strDay As String = ""

        strUserBeginDate = clsDateFormat.chkDateThOrEn(clsDateFormat.enmDateCultureInfo.Th, Date.Now)

        strDay = tblSystemConfig.Where(Function(fn) fn.CONFIGCODE = "C01")(0).CONFIGNUM 'วันหมดอายุรหัสผ่าน Admin
        strPwdExpireDateAdmin = clsDateFormat.chkDateThOrEn(clsDateFormat.enmDateCultureInfo.Th, Date.Now.AddDays(strDay))

        strDay = tblSystemConfig.Where(Function(fn) fn.CONFIGCODE = "C07")(0).CONFIGNUM 'วันหมดอายุรหัสผ่าน User
        strPwdExpireDateUser = clsDateFormat.chkDateThOrEn(clsDateFormat.enmDateCultureInfo.Th, Date.Now.AddDays(strDay))

        strDay = tblSystemConfig.Where(Function(fn) fn.CONFIGCODE = "C06")(0).CONFIGNUM 'วันหมดอายุUser 
        strUserExpireDate = clsDateFormat.chkDateThOrEn(clsDateFormat.enmDateCultureInfo.Th, Date.Now.AddDays(strDay))



        clsDateFormat = Nothing

    End Sub

    Public Sub setdefaultValueString()
        Dim clsEn As New clsEdmUser
        '
        Dim str_Password As String = ""
        str_Password = tblSystemConfig.Where(Function(fn) fn.CONFIGCODE = "C08")(0).CONFIGSTR 'ค่าเริ่มต้นรหัสผ่าน
        strPassword = clsEn.DecryPass(str_Password)

    End Sub


    Public Function chkDupPwd(ByRef strPass As String) As Boolean
        Dim chk As Boolean = False
        If (strPassword = strPass) Then
            chk = True
        End If

        Return chk
    End Function
End Class
